local sk__wuzhi = fk.CreateSkill {

  name = "sk__wuzhi",

  tags = { Skill.Compulsory, },

}



sk__wuzhi:addEffect(fk.EventPhaseStart, {
  name = "sk__wuzhi",
  anim_type = "negative",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(sk__wuzhi.name) and player.phase == Player.Finish and player:getMark("sk__wuzhi-turn") > 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:damage{
      to = player,
      damage = 1,
      skillName = sk__wuzhi.name,
    }
    if player.dead then return end
    local card = room:getCardsFromPileByRule("slash", 1, "drawPile")
    if #card > 0 then
      room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonJustMove, sk__wuzhi.name, nil, true, player)
    end
  end,
})
sk__wuzhi:addEffect(fk.EventPhaseEnd, {
  can_refresh = function(self, event, target, player, data)
    return target == player and player:hasSkill(self, true) and player.phase == Player.Play
  end,
  on_refresh = function(self, event, target, player, data)
    local card = Fk:cloneCard("slash")
    local slash_skill = card.skill
    local status_skills = Fk:currentRoom().status_skills[TargetModSkill] or Util.DummyTable
    for _, skill in ipairs(status_skills) do
      if skill:bypassTimesCheck(player, slash_skill, Player.HistoryPhase, card, nil) then return true end
    end
    if player:usedCardTimes("slash", Player.HistoryPhase) < slash_skill:getMaxUseTime(player, Player.HistoryPhase, card, nil) then
      player.room:setPlayerMark(player, "sk__wuzhi-turn", 1)
    end
  end,
})

return sk__wuzhi